//
//  main.m
//  03-NSArrayAndNSMutableArray
//
//  Created by 曹曹 on 16/7/6.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Book.h"
#import "BookManager.h"

int main(int argc, const char * argv[]) {
//    1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
//    2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
//    3.实现图书管理系统(BookManager类)：
//    使用数组管理所有书籍(Book类)。
//    BookManager类属性数组可以添加、删除。
//    可以从数组根据书名查找书籍，并修改书籍的价格。
//    展示所有书籍清单（书名）
#pragma mark - 1
    NSString *seperateString = @"20|https://www.baidu.com";
    NSArray *seperateArray = [seperateString componentsSeparatedByString:@"|"];
    NSLog(@"seperateArray is %@", seperateArray);
#pragma mark - 2
    int a = 10;
    float b = 10;
    double c = 10;
    BOOL d = YES;
    NSString *intValue = [NSString stringWithFormat:@"%d", a];
    NSString *floatValue = [NSString stringWithFormat:@"%f", b];
    NSString *doubleValue = [NSString stringWithFormat:@"%f", c];
    NSString *boolValue = [NSString stringWithFormat:@"%d", d];
    NSMutableArray *mArray = [NSMutableArray arrayWithObjects:intValue, floatValue, doubleValue, boolValue, nil];
    NSLog(@"mArray is %@", mArray);
#pragma mark - 3
    Book *book1 = [Book bookWithName:@"象牙塔" price:@"23"];
    Book *book2 = [Book bookWithName:@"洛丽塔" price:@"32"];
    Book *book3 = [Book bookWithName:@"草房子" price:@"33"];
    Book *book4 = [Book bookWithName:@"易筋经" price:@"34"];
    BookManager *manager = [BookManager manager];
    manager.bookArray = [NSMutableArray arrayWithObjects:book1, book2, book3, book4, nil];
    [manager checkoutForBook:@"哦哈呦"];
    [manager addBook:@"水浒传" price:@"44"];
    [manager showAllBooks];
    [manager addBook:@"象牙塔" price:@"1"];
    [manager deleteBook:@"洛丽塔"];
    [manager showAllBooks];
    [manager setBook:@"哎呦喂" price:@"45"];
    [manager setBook:@"易筋经" price:@"66"];
    [manager showAllBooks];
    return 0;
}
